#!/bin/bash
#
# pf_ring   Load the pfring driver
#
# chkconfig: 2345 30 60
#
# (C) 2003-17 - ntop.org
#
### BEGIN INIT INFO
# Provides:       pf_ring
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop:  ntopng n2disk nprobe cento cluster
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description: Start/stop pf_ring
### END INIT INFO

if hash systemctl 2>/dev/null; then
    echo "This host is systemd based."
    echo "Please used systemctl <command> instead of init.d scripts"
    exit 0
fi

#Needed to skip systemctl redirect in ubuntu 16
_SYSTEMCTL_SKIP_REDIRECT=yes

ACTION="status"

case "$1" in
  start)
	ACTION="start-if-enabled"
	;;

  stop)
	ACTION="stop"
	;;

  restart)
	ACTION="restart-if-enabled"
	;;

  force-start | forcestart)
	ACTION="start"
	;;

  force-restart | forcerestart)
	ACTION="restart"
	;;

  status)
	ACTION="status"
	;;

  *)
	echo "Usage: /etc/init.d/pf_ring {start|stop|restart|force-start|force-restart|status}"
	exit 1
esac

/usr/bin/pf_ringctl ${ACTION}

exit 0
